package com.xjm.ips.service;

import com.xjm.ips.entity.Employee;
import com.xjm.ips.entity.Employeeec;
import com.xjm.ips.entity.MyPage;
import com.xjm.ips.mapper.EmployeeecMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class PersonnelEcService {
    @Autowired
    EmployeeecMapper employeeecMapper;

    public MyPage getEmployeeEc(Integer pageNo, Integer pageSize, Employeeec employeeec) {
        if(pageNo!=null && pageSize!=null){
            pageNo = (pageNo-1)*pageSize;
        }
        List<Employeeec> data = employeeecMapper.getEmployeeEc(pageNo,pageSize,employeeec);
        Long total = employeeecMapper.getTotal(employeeec);
        MyPage myPage = new MyPage();
        myPage.setData(data);
        myPage.setTotal(total);
        return myPage;
    }

    public Integer addEmployeeEc(Employeeec employeeec) {
        employeeec.setEcDate(new Date());
        return employeeecMapper.insertSelective(employeeec);
    }

    public Integer updateEmpolyeeEc(Employeeec employeeec) {
        return employeeecMapper.updateByPrimaryKeySelective(employeeec);
    }

    public Integer deleteEmployeeEc(Integer id) {
        return employeeecMapper.deleteByPrimaryKey(id);
    }

}

